/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package to.pm.magazzino.ejb;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import to.pm.entity.acquisti.OrdineEsterno;

/**
 *
 * @author fra
 */
@MessageDriven(mappedName = "jms/QOrdineEsterno", activationConfig =  {
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
        @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
    })
public class NotificaOrdineEsternoBean implements MessageListener {

    Logger log = Logger.getAnonymousLogger();

    public NotificaOrdineEsternoBean() {
    }

    public void onMessage(Message message) {
        log.info("Ricevuto: "+message);
        OrdineEsterno o = null;
        try {
            o = (OrdineEsterno) ((ObjectMessage)message).getObject();
        } catch (JMSException ex) {
            Logger.getLogger(NotificaOrdineEsternoBean.class.getName()).log(Level.SEVERE, null, ex);
        }
        log.info("Contenuto: "+o);
    }
    
}
